<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>商家列表</title>
    <script src="__INDEX__/js/mui.min.js"></script>
    <link href="__INDEX__/css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
    <link rel="stylesheet" href="__INDEX__/css/style.css" />
    <link rel="stylesheet" href="__INDEX__/css/yund.css" />
    <script type="text/javascript" src="__INDEX__/dist/jquery.min.js" ></script>
	<script type="text/javascript" src="__INDEX__/js/menudown.js" ></script>
</head>
<style>
	.my_li{
		border-bottom: 1px solid #d6cfcf;
	}
	.mystyl{
	    height: 3rem;
	    width: 100%;
	    line-height: 3rem;
	    text-align: center;
	    border-bottom: 1px solid #E6E6E6;
	    position: relative;
	    border-left: 2px solid -webkit-linear-gradient(red, blue);
	    background: white;
	}
</style>
<body>
	<header class="mui-bar mui-bar-nav">
	    <h1 class="mui-title">商家列表</h1>
	</header>
	<div class="mui-content shop_content">
	    <ul class="fjsj_list" id='item_ul'>
			<!--<li>
				<a href="#">
					<div class="sjimg"><img src="__INDEX__/images/video.jpg"></div>
					<div class="infobox">
						<div class="nambox clearfix">
							<span class="name">重庆德庄火锅</span>
							<span class="time">3-21</span>
						</div>
						<div class="sjhd">100元抵扣券<em>30</em>元限时抢购</div>
						<div class="adress">地址：友谊阿波罗国际广场6楼6022</div>
					</div>
				</a>
			</li>-->
		</ul>	   
		<p id="over" style="display: none;text-align: center;">
				数据已经已经加载完
			</p>
		<input type="hidden" id='agent_type' value="0"/>
		<input type="hidden" id='town_name' value="0"/>
		<input type="hidden" id='juli' value="0"/>
		<input type="hidden" id='longitude' value="0"/>
		<input type="hidden" id='latitude' value="0"/>
	</div>
	<input type="hidden" id="page" value="1" />
	 {include file="public/bottom" /}
</body>
</html>
{include file="public/footer" /}
<script>
	function sel_agent_type(){
		$('#agent_type').val($('#agent_type_ul>.focus')[0].value);
		
		$("#item_ul").empty();
		get_data(113.010009,25.775168);
	}
	
	
	function sel_address_type(){
		
		$('#town_name').val($('#address_type_ul>.focus')[0].innerText.trim());
		
		$("#item_ul").empty();
		get_data(113.010009,25.775168);
	}
	
	
	function sel_juli(){
		var juli_type = $('#juli').val();
		if(juli_type == 1){
			$('#juli').val(2);
		}else{
			$('#juli').val(1);
		}
		
		$("#item_ul").empty();
		get_data(113.010009,25.775168);
	}
	
</script>
<script>
/*var map, geolocation;
function my_getAddress(){
    //加载地图，调用浏览器定位服务
    map = new AMap.Map('container', {
        resizeEnable: true
    });
    map.plugin('AMap.Geolocation', function() {
        geolocation = new AMap.Geolocation({
            enableHighAccuracy: true,//是否使用高精度定位，默认:true
            timeout: 10000,          //超过10秒后停止定位，默认：无穷大
            buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
            zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            buttonPosition:'RB'
        });
        map.addControl(geolocation);
        geolocation.getCurrentPosition();
        AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
    });
    $('#container').hide();
    //解析定位结果
    function onComplete(data) {
    	get_data(data.position.getLng(),data.position.getLat());
    }
}*/
get_data(113.010009,25.775168);
var load=true;
function get_data(lng,lat){
	
	lng = 113.010009;
	lat = 25.775168;
	$('#longitude').val(lng);
	$('#latitude').val(lat);
    	$.ajax({
		   	type:"post",
		   	data:{
		   		juli		:$('#juli').val(),
		   		town_name	:$('#town_name').val(),
		   		agent_type	:$('#agent_type').val(),
		   		longitude	: lng,
		   		latitude	: lat,
		   		page		: $('#page').val()
		   	},
		   	url:"{:url('shop/shoplist')}",
		   	success:function(data){
		   		var agent_list = data.data;
		   		$("#page").val(parseFloat($("#page").val()) + 1);
		   		if(agent_list&&agent_list.length>0){
		   		for(var i=0;i<agent_list.length;i++){
		   			var juli = agent_list[i].juli;
		   			if(juli<1000){
		   				juli = juli+"m";
		   			}else{
		   				juli = juli/1000+"km";
		   			}
		   			if(agent_list[i].logo != null){
		   				var logo = agent_list[i].logo;
		   			}else{
		   				var logo = '__INDEX__/bg.png';
		   			}
		   			cut_url = "/index/shop/shop?agent_id="+agent_list[i].id;
		   			var html =	"<li>"+
		   					"<a href='"+cut_url+"'>"+
			    			"<div class='sjimg'><img src='"+logo+"'></div>"+
			    				"<div class='infobox'>"+
			    					"<div class='nambox clearfix'>"+
			    						"<span class='name'>"+agent_list[i].agent_name+"</span>"+
			    						"<span class='time'>"+juli+"</span>"+
			    					"</div>"+
			    					"<div class='sjhd'>电话：<em>"+agent_list[i].mobile+"</em></div>"+
			    					"<div class='adress'>地址："+agent_list[i].address+"</div>"+
			    				"</div></a></li>";
		   			$('#item_ul').append(html);
		   		} 
		   				
		   		}else{
		   			$("#over").show();
		   		}
		   	}
		})
 }


	$(window).scroll(function() {
		var scrollTop = $(this).scrollTop(); //滑过的文档高度  
		var scrollHeight = $(this).height(); //文档高度  
		var windowHeight = window.innerHeight; //浏览器窗口高度  
		if(($(window).scrollTop() + $(window).height() > $(document).height() - 10) && load) {
			var index = layer.load(0, {
				shade: false,
				time: 1.5 * 1000
			});
			$(".layui-layer-loading").css("left", "50%");
			load = false;
			get_data(113.010009,25.775168);
		}
	})

</script>